<template>
  <div class="orderitem">
    <div class="top-orderitem">
      <van-icon name="arrow-left" class="top-left" @click="goback()" />
      <span class="p1">预约课程</span>
    </div>
    <div class="center-item" v-for="(item,index) in teacherList" :key="index">
      <div class="left-item">
        <img :src="item.avatar" />
      </div>
      <div class="right-item">
        <span>{{item.real_name}}</span>
        <p>{{item.introduction}}</p>
        <button class="btn1" @click="tojj()">查看详情</button>
      </div>
    </div>
   <!--  -->
   <div class="time">
      <p class="time_p">选择时间<span class="time_span">(北京时间)</span></p>
    </div>
    <div class="week">
      <div class="divdiv">
        <p>周一</p>
        <p class="item_describe">9/28</p>
      </div>
      <div class="divdiv">
        <p>周二</p>
        <p class="item_describe">9/29</p>
      </div>
      <div class="divdiv">
        <p>周三</p>
        <p class="item_describe">9/30</p>
      </div>
      <div class="divdiv">
        <p>周四</p>
        <p class="item_describe">10/01</p>
      </div>
      <div class="divdiv">
        <p>周五</p>
        <p class="item_describe">10/02</p>
      </div>
    </div>
    <div class="hou" @click="dian">立即预约</div>
  </div>
</template>

<script>
import { ywtOrdercourse } from "../../util/http";
import {Toast} from "vant";
export default {
  data() {
    return {
      orderlist: [],
      id: 0,
      teacherList: [],
      date: "",
      show: false,
      showModal: false
    };
  },
  mounted() {
    this.id = this.$route.query.id;
    this.orderget();
  },
  methods: {
    async orderget() {
      var arr = []; //12
      for (var a = 1; a <= 4; a++) {
        let date = {
          id: this.id,
          page: a //2
        };
        await ywtOrdercourse(date).then(res => {
          res.data.filter(item => {
            arr.push(item);
          });
        });
      }
      let teacherListOne = arr.filter(item => {
        return item.id == this.id;
      });
      this.teacherList = teacherListOne;
      console.log(this.teacherList);
    },
    tojj() {
      this.$router.push({
        path: "/teacherdetail"
      });
    },
    goback() {
      this.$router.go(-1);
    },
    formateDate(date) {
      return `${data.getMonth() + 1}/${date.getData}`;
    },
    onConfirm(date) {
      this.show = false;
      this.date = this.formateDate(date);
    },
    dian(){
      Toast({
      message: "请选择预约时间",
        position: "bottom",
      })
    }
  }
};
</script>

<style lang="scss">
.top-orderitem {
  width: 100%;
  height: 10vh;
  background-color: rgb(96, 173, 249);
  display: flex;
  align-items: center;
}
.top-left {
  font-size: 24px;
  color: white;
}
.p1 {
  color: white;
  font-size: 18px;
  margin-left: 3rem;
}
.center-item {
  width: 90%;
  height: 2.4rem;
  background-color: #fff;
  position: absolute;
  left: 0.4rem;
  top: 1.4rem;
}
.right-item {
  margin-left: 2.9rem;
  margin-top: -1.2rem;
}
.left-item img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-top: 0.1rem;
  margin-left: 0.6rem;
}

.right-item span {
  font-size: 0.4rem;
}
.right-item p {
  color: gray;
  font-size: 0.3rem;
  // 内容超出后隐藏
  overflow: hidden;
  //超出内容显示为省略号
  text-overflow: ellipsis;
  // 文本不进行换行
  white-space: nowrap;
}
.right-item .btn1 {
  width: 2.1rem;
  height: 0.8rem;
  border: none;
  border-radius: 24%;
  color: red;
  line-height: 0.6rem;
  background-color: #fff;
  border: 1px solid red;
  position: absolute;
  left: 6.4rem;
  top: 1.6rem;
}

.time {
  width: 90%;
  height: 0.4rem;
  border-left: 0.09rem solid orange;
  margin: 0 auto;
  margin-top: 5rem;
}

.time_p {
  font-size: 0.3rem;
  color: gray;
  margin-left: 0.2rem;
}

.time_span {
  font-size: 0.1rem;
  line-height: 0.4rem;
  margin-left: 0.2rem;
}

.week {
  width: 100%;
  height: 1.5rem;
  display: flex;
  flex-direction: row;
  flex-wrap: no-wrap;
  margin-top: 0.2rem;
  overflow-x: scroll;
  overflow: hidden;
}

.divdiv {
  width: 1rem;
  height: 1.5rem;
  margin: 0 auto;
  font-size: 0.3rem;
  color: gray;
  text-align: center;
}

.divdiv:hover {
  color: orangered;
}

.hou {
  width: 100%;
  height: 1rem;
  background: orangered;
  color: white;
  text-align: center;
  line-height: 1rem;
  font-size: 0.4rem;
  margin-top: 7.7rem;
}
</style>